package structuralPatterns.bridge;

abstract class Pen {
    protected Color color;

    public Pen(Color color) {
        this.color = color;
    }

    abstract void draw(String name);
}

class SmailPen extends Pen {
    public SmailPen(Color color) {
        super(color);
    }

    public void draw(String name) {
        color.bepaint("smail pen", name);
    }
}

class BigPen extends Pen {
    public BigPen(Color color) {
        super(color);
    }

    public void draw(String name) {
        color.bepaint("big pen", name);
    }
}

interface Color {
    void bepaint(String penType, String name);
}

class Red implements Color {
    public void bepaint(String penType, String name) {
        System.out.println("The " + penType + " is red and draws " + name);
    }
}

class Green implements Color {
    public void bepaint(String penType, String name) {
        System.out.println("The " + penType + " is green and draws " + name);
    }
}

public class BridgePattern {
    public static void main(String[] args) {
        Pen pen = new SmailPen(new Red());
        pen.draw("Tom");

        pen = new BigPen(new Green());
        pen.draw("Jerry");
    }
}
